import { PureComponent } from 'react';
import moment from 'moment';
import {
    Row,
    Col,
    Form,
    Input,
    Select,
    Modal,
    Cascader,
    DatePicker
} from 'antd';
const FormItem = Form.Item;
const { Option } = Select;
import { dicTextByCodePcode,dicListByPcode } from '@/utils/dictionary'


@Form.create()
class CreateForm extends PureComponent {

	constructor(props) {
	    super(props);
	    this.state = {

	    }
	}


	okHandle = () => {
		const { form,handleAdd } = this.props;

	    form.validateFields((err, fieldsValue) => {
		        if (err) return;
		        form.resetFields();
			   	if(fieldsValue.a1021) {
			   				fieldsValue.a1021 = moment(fieldsValue.a1021._d).format("YYYY-MM-DD");
			   			}
			   	if(fieldsValue.a1014) {
			   				fieldsValue.a1014 = moment(fieldsValue.a1014._d).format("YYYY-MM-DD");
			   			}
			   	if(fieldsValue.a1004) {
			   				fieldsValue.a1004 = moment(fieldsValue.a1004._d).format("YYYY-MM-DD");
			   			}
			    handleAdd(fieldsValue,'PoliceRankInfo');
		});
	};


	resetButton = () => {

	};

  render() {
    const {form: {getFieldDecorator}, modalVisibleByPoliceRankInfo,handleModalVisible} = this.props;

return (
    <Modal
width={800}
destroyOnClose
title="添加警衔信息"
visible={modalVisibleByPoliceRankInfo}
onOk={this.okHandle}
onCancel={() => handleModalVisible(false,"PoliceRankInfo")}
afterClose={() => this.resetButton()}
>
<Form  layout="vertical">
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		    <Col md={12} sm={24}>
		      <FormItem  label="衔称">
		          {getFieldDecorator('a1001', {
		          rules: [{ required: false, message: '请选择',max: 10}],
		          })(
		          <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          	{dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		          		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          	}):null}
		          </Select>
		          )}
		      </FormItem>
		    </Col>
		
		    <Col md={12} sm={24}>
		      <FormItem  label="警衔类型">
		          {getFieldDecorator('a1001_1', {
		            rules: [{ required: false, message: '请选择'}],
		          })(
		            <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		            	{dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		            		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		            	}):null}
		            </Select>
		          )}
		      </FormItem>
		    </Col>
		
		</Row>
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		    <Col md={12} sm={24}>
		      <FormItem  label="衔称变动原因">
		          {getFieldDecorator('a1024',{
		          })(
		          	<Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          		{dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		          			return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          		}):null}
		          	</Select>
		          )}
		      </FormItem>
		    </Col>
		    <Col md={12} sm={24}>
		      <FormItem  label="起算日期">
		          {getFieldDecorator('a1021', {
		          rules: [{ required: false, message: '请选择'}],
		          })(<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>)}
		      </FormItem>
		    </Col>
		
		</Row>
		
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		<Col md={12} sm={24}>
		      <FormItem  label="终止日期">
		          {getFieldDecorator('a1014', {
		          rules: [{ required: false, message: '请选择'}],
		              })(<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>)}
		       </FormItem>
		    </Col>
		
		    <Col md={12} sm={24}>
		      <FormItem  label="授衔日期">
		          {getFieldDecorator('a1004', {
		             rules: [{ required: false, message: '请选择'}],
		                 })(<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>)}
		      </FormItem>
		    </Col>
		
		</Row>
		
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		
		    <Col md={12} sm={24}>
		      <FormItem  label="授衔批准单位名称">
		          {getFieldDecorator('a1007_1', {
		          rules: [{ required: false, message: '1-40个字符'}],
		          })(
		            <Input placeholder="1-40个字符" />
		          )}
		      </FormItem>
		    </Col>
		    <Col md={12} sm={24}>
		      <FormItem  label="授衔令号">
		          {getFieldDecorator('a1011', {
		          rules: [{ required: false, message: '1-40个字符'}],
		          })(<Input placeholder="1-40个字符" />)}
		      </FormItem>
		    </Col>
		
		</Row>
		
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
		
		    <Col md={12} sm={24}>
		      <FormItem  label="授衔批准单位代码">
		          {getFieldDecorator('a1007_2', {
		         rules: [{ required: false, message: '1-40个字符'}],
		             })(<Input placeholder="1-40个字符" />)}
		         </FormItem>
		    </Col>
		
		   	<Col  md={12} sm={24}>
		   	  <FormItem  label="衔称状态">
		   	      {getFieldDecorator('a0317', {
		   	        rules: [{ required: false, message: '请选择'}],
		   	        })(
		              <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		                {dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		                  return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		                }):null}
		              </Select>
		            )}
		   	  </FormItem>
		   	</Col>
		
		</Row>
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
			<Col md={12} sm={24}>
			  <FormItem  label="授衔来源">
			      {getFieldDecorator('a1027', {
			        rules: [{ required: false, message: '请选择'}],
			        })(
			        <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
			        	{dicListByPcode('BG') != undefined?dicListByPcode('BG').map((item,index) => {
			        		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
			        	}):null}
			        </Select>
			      )}
			  </FormItem>
			</Col>
		
		  <Col md={12} sm={24}>
		    <FormItem  label="警衔取消原因">
		        {getFieldDecorator('a1029', {
		          rules: [{ required: false, message: '请选择'}],
		          })(
		          <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          	{dicListByPcode('JK') != undefined?dicListByPcode('JK').map((item,index) => {
		          		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          	}):null}
		          </Select>
		        )}
		    </FormItem>
		  </Col>
		</Row>
		
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
		
			<Col md={12} sm={24}>
			  <FormItem  label="警衔保留原因">
			      {getFieldDecorator('a1028', {
			        rules: [{ required: false, message: '请选择'}],
			        })(
			        <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
			        	{dicListByPcode('BG') != undefined?dicListByPcode('BG').map((item,index) => {
			        		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
			        	}):null}
			        </Select>
			      )}
			  </FormItem>
			</Col>
		
		  <Col md={12} sm={24}>
		    <FormItem  label="警衔不保留原因">
		        {getFieldDecorator('a1030', {
		          rules: [{ required: false, message: '请选择'}],
		          })(
		          <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          	{dicListByPcode('JK') != undefined?dicListByPcode('JK').map((item,index) => {
		          		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          	}):null}
		          </Select>
		        )}
		    </FormItem>
		  </Col>
		</Row>

</Form>
</Modal>
);
  }

}

export default CreateForm;
